<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Script-Type" content="text/css" />

<title>无标题文档</title>
<script type="text/javascript">

function click(e)
{
	alert("添加成功");
	//new_standart.innerText = this.id;
}
function clickme()
{
	var form = document.getElementById("standardForm");
	form.name.value = document.getElementById("data").childNodes[0].innerText;
	//form.classification.value = document.getElementById("data").childNodes[1].innerText;
	form.max.value = document.getElementById("data").childNodes[2].innerText;
	form.min.value = document.getElementById("data").childNodes[3].innerText;
	alert(form.name.value);
	form.submit();
}

/* 

Tablecloth 
written by Alen Grakalic, provided by Css Globe (cssglobe.com)
please visit http://cssglobe.com/lab/tablecloth/

*/

this.tablecloth = function(){

// CONFIG 

// if set to true then mouseover a table cell will highlight entire column (except sibling headings)
var highlightCols = true;

// if set to true then mouseover a table cell will highlight entire row	(except sibling headings)
var highlightRows = false;	

// if set to true then click on a table sell will select row or column based on config
var selectable = true;
var cobj = null;
// this function is called when 
// add your own code if you want to add action 
// function receives object that has been clicked 
this.clickAction = function(obj){
	
if(obj.id =="new"){
	if(obj==cobj)
		{return;}
	else
	{
	  if(cobj!=null)
	  {
		  var text = document.getElementById("text").value;
		  if (text == "")
			  {
			    text = "input";
			  }
		  cobj.innerHTML = "";
	      cobj.innerText = text;
	  }
	  cobj = obj;
      cobj.innerHTML = "<input type = 'button'  id = 'text'/>";
    }
}
else 
	{
	   if(cobj!=null)
	   {
		   var text = document.getElementById("text").value;
			  cobj.innerHTML = "";
		      cobj.innerText = text;
		}
	}
};

// END CONFIG (do not edit below this line)
var tableover = false;
this.start = function(){
	var tables = document.getElementsByTagName("table");
	for (var i=0;i<tables.length;i++){
		tables[i].onmouseover = function(){tableover = true;};
		tables[i].onmouseout = function(){tableover = false;};			
		rows(tables[i]);
	};
};

this.rows = function(table){
	var css = "";
	var tr = table.getElementsByTagName("tr");
	for (var i=0;i<tr.length;i++){
		css = (css == "odd") ? "even" : "odd";
		tr[i].className = css;
		var arr = new Array();
		for(var j=0;j<tr[i].childNodes.length;j++){				
			if(tr[i].childNodes[j].nodeType == 1) arr.push(tr[i].childNodes[j]);
		};		
		for (var j=0;j<arr.length;j++){				
			arr[j].row = i;
			arr[j].col = j;
			if(arr[j].innerHTML == "&nbsp;" || arr[j].innerHTML == "") arr[j].className += " empty";					
			arr[j].css = arr[j].className;
			arr[j].onmouseover = function(){
				over(table,this,this.row,this.col);
			};
			arr[j].onmouseout = function(){
				out(table,this,this.row,this.col);
			};
			arr[j].onmousedown = function(){
				down(table,this,this.row,this.col);
			};
			arr[j].onmouseup = function(){
				up(table,this,this.row,this.col);
			};				
			arr[j].onclick = function(){
				click(table,this,this.row,this.col);
			};								
		};
	};
};

// appyling mouseover state for objects (th or td)
this.over = function(table,obj,row,col){
	if (!highlightCols && !highlightRows) obj.className = obj.css + " over";  
	if(check1(obj,col)){
		if(highlightCols) highlightCol(table,obj,col);
		if(highlightRows) highlightRow(table,obj,row);		
	};
};
// appyling mouseout state for objects (th or td)	
this.out = function(table,obj,row,col){
	if (!highlightCols && !highlightRows) obj.className = obj.css; 
	unhighlightCol(table,col);
	unhighlightRow(table,row);
};
// appyling mousedown state for objects (th or td)	
this.down = function(table,obj,row,col){
	obj.className = obj.css + " down";  
};
// appyling mouseup state for objects (th or td)	
this.up = function(table,obj,row,col){
	obj.className = obj.css + " over";  
};	
// onclick event for objects (th or td)	
this.click = function(table,obj,row,col){
	if(check1){
		if(selectable) {
			unselect(table);	
			if(highlightCols) highlightCol(table,obj,col,true);
			if(highlightRows) highlightRow(table,obj,row,true);
			document.onclick = unselectAll;
		}
	};
	clickAction(obj); 		
};		

this.highlightCol = function(table,active,col,sel){
	var css = (typeof(sel) != "undefined") ? "selected" : "over";
	var tr = table.getElementsByTagName("tr");
	for (var i=0;i<tr.length;i++){	
		var arr = new Array();
		for(j=0;j<tr[i].childNodes.length;j++){				
			if(tr[i].childNodes[j].nodeType == 1) arr.push(tr[i].childNodes[j]);
		};							
		var obj = arr[col];
		if (check2(active,obj) && check3(obj)) obj.className = obj.css + " " + css; 		
	};
};
this.unhighlightCol = function(table,col){
	var tr = table.getElementsByTagName("tr");
	for (var i=0;i<tr.length;i++){
		var arr = new Array();
		for(j=0;j<tr[i].childNodes.length;j++){				
			if(tr[i].childNodes[j].nodeType == 1) arr.push(tr[i].childNodes[j]);
		};				
		var obj = arr[col];
		if(check3(obj)) obj.className = obj.css; 
	};
};	
this.highlightRow = function(table,active,row,sel){
	var css = (typeof(sel) != "undefined") ? "selected" : "over";
	var tr = table.getElementsByTagName("tr")[row];		
	for (var i=0;i<tr.childNodes.length;i++){		
		var obj = tr.childNodes[i];
		if (check2(active,obj) && check3(obj)) obj.className = obj.css + " " + css; 		
	};
};
this.unhighlightRow = function(table,row){
	var tr = table.getElementsByTagName("tr")[row];		
	for (var i=0;i<tr.childNodes.length;i++){
		var obj = tr.childNodes[i];			
		if(check3(obj)) obj.className = obj.css; 			
	};
};
this.unselect = function(table){
	tr = table.getElementsByTagName("tr");
	for (var i=0;i<tr.length;i++){
		for (var j=0;j<tr[i].childNodes.length;j++){
			var obj = tr[i].childNodes[j];	
			if(obj.className) obj.className = obj.className.replace("selected","");
		};
	};
};
this.unselectAll = function(){
	if(!tableover){
		tables = document.getElementsByTagName("table");
		for (var i=0;i<tables.length;i++){
			unselect(tables[i]);
		};		
	};
};	
this.check1 = function(obj,col){
	return (!(col == 0 && obj.className.indexOf("empty") != -1));
};
this.check2 = function(active,obj){
	return (!(active.tagName == "TH" && obj.tagName == "TH")); 
};
this.check3 = function(obj){
	return (obj.className) ? (obj.className.indexOf("selected") == -1) : true; 
};	

start();

};

/* script initiates on page load. */
window.onload = tablecloth;
</script>

<style type = "text/css">
<!--
  #view1{
  width:900px;
  height:600px;
  background-color:#00CCFF;
  }
  
table, td{
	font:100% Arial, Helvetica, sans-serif; 
}
table{width:100%;border-collapse:collapse;margin:1em 0;}
th, td{text-align:left;padding:.5em;border:1px solid #fff;}
th{background:#328aa4 url(tr_back.gif) repeat-x;color:#fff;}
td{background:#e5f1f4;}

th.title{background:#ffff66;color:blue;}

/* tablecloth styles */

tr.even td{background:#e5f1f4;}
tr.odd td{background:#f8fbfc;}

th.over, tr.even th.over, tr.odd th.over{background:#4a98af;}
th.down, tr.even th.down, tr.odd th.down{background:#bce774;}
th.selected, tr.even th.selected, tr.odd th.selected{}

td.over, tr.even td.over, tr.odd td.over{background:#ecfbd4;}
td.down, tr.even td.down, tr.odd td.down{background:#bce774;color:#fff;}
td.selected, tr.even td.selected, tr.odd td.selected{background:#bce774;color:#555;}

/* use this if you want to apply different styleing to empty table cells*/
td.empty, tr.odd td.empty, tr.even td.empty{background:#fff;}
  
-->

a.gb{color:#11c !important}
	.oneColFixCtrHdr #header {
	background: #DDDDDD; 
	padding: 0 10px 0 20px;
    }
	#headerleft{float:left;}
	#headerright{float:right;}
	
	#center{ 
	padding: 0 10px 0 20px;
	}
	.clearfloat { /* 此类应当放在 div 或 break 元素上，而且该元素应当是完全包含浮动的容器关闭之前的最后一个元素 */
	clear:both;
    height:0;
    font-size: 1px;
    line-height: 0px;
    }
	.ds{
	border-bottom:solid 1px #e7e7e7;
	border-right:solid 1px #e7e7e7;
	margin:3px 0 4px;
	margin-left:4px
	}
	.lsb{
	font:15px arial,sans-serif;
	border:none;
	color:#000;
	cursor:pointer;
	height:30px;
	margin:0;
	padding:0 6px;
	width:auto;
	overflow:visible;
	vertical-align:top
	}
	.lsb:active{background:#ccc}
</style>
</head>


<body>
<input type="button" id= "change" value="change!!" onclick = "clickme()" />


<h2>Table with top headings</h2>
	<center>
	        <form action = "../standard/newStandard.do" method="post" id="standardForm">
				<input type="hidden" name="name" />
				<input type="hidden" name="max" />
				<input type="hidden" name="min" />
			</form>
		<table id = "t" cellspacing="0" cellpadding="0">
			<tr>
				<th id = "standard">标准</th>
				<th id = "classification">分类</th>
				<th id = "max">最大值</th>
				<th id = "min">最小值</th>
			</tr>
			
			<tr id = "data">
				<td id ="new">Data</td>
				<td id ="new">Data</td>
				<td id ="new">Data</td>
				<td id ="new">Data</td>
			</tr>	
			<%@ page import="db.standard.Standard" %>
            <%@ page import="java.util.List" %>		
			<%
			@SuppressWarnings("unchecked")
			List<Standard> s = (List<Standard>)request.getAttribute("standards");
			
			for(int i=0; i<s.size();i++)
			{
				out.print("<tr>");
                out.print("<td>"+s.get(i).getName()+"</td>");
                out.print("<td>"+"</td>");
				
				/*newTr.className = css;
				var newTd0 = newTr.insertCell();
				newTd0.innerText = css;
				var newTd1 = newTr.insertCell();
				newTd1.innerText= css;
				var newTd2 = newTr.insertCell();
				newTd2.innerText= css;
				var newTd3 = newTr.insertCell();
				newTd3.innerText= css;	
				var newTd4 = newTr.insertCell();
				newTd4.innerText= css;*/
				out.print("</tr>");
			}
			%>								
		</table>
</center>

</body>
</html>
